home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 41.zip / BS1 part 41 / Abacus diskdrives IO.adf / CH5 / typefile.c < prev    next >
C/C++ Source or Header  |  1978-06-28  |  4KB  |  127 lines

  1.  
  2. /*---------------------------------------------------------------------*/
  3. /*                     Call of the  DOS-Functions                      */
  4. /*                                                                     */
  5. /*                           JEA, 18-08-87                             */
  6. /*---------------------------------------------------------------------*/
  7. #include <exec/exec.h>
  8. #include <libraries/dos.h>
  9. #include <libraries/dosextens.h>
  10. #include <libraries/filehandler.h>
  11. #include <stdio.h>
  12.  
  13. char *error_strs[] = {
  14. "ERROR_NO_DEFAULT_DIR: 201",
  15. "ERROR_OBJECT_IN_USE: 202",
  16. "ERROR_OBJECT_EXISTS: 203",
  17. "ERROR_DIR_NOT_FOUND: 204",
  18. "ERROR_OBJECT_NOT_FOUND: 205",
  19. "ERROR_BAD_STREAM_NAME: 206",
  20. "ERROR_OBJECT_TOO_LARGE: 207",
  21. "ERROR_ACTION_NOT_KNOWN: 209",
  22. "ERROR_INVALID_COMPONENT_NAME: 210",
  23. "ERROR_INVALID_LOCK: 211",
  24. "ERROR_OBJECT_WRONG_TYPE: 212",
  25. "ERROR_DISK_NOT_VALIDATED: 213",
  26. "ERROR_DISK_WRITE_PROTECTED: 214",
  27. "ERROR_RENAME_ACROSS_DEVICES: 215",
  28. "ERROR_DIRECTORY_NOT_EMPTY: 216",
  29. "ERROR_TOO_MANY_LEVELS: 217",
  30. "ERROR_DEVICE_NOT_MOUNTED: 218",
  31. "ERROR_SEEK_ERROR: 219",
  32. "ERROR_COMMENT_TOO_BIG: 220",
  33. "ERROR_DISK_FULL: 221",
  34. "ERROR_DELETE_PROTECTED: 222",
  35. "ERROR_WRITE_PROTECTED: 223",
  36. "ERROR_READ_PROTECTED: 224",
  37. "ERROR_NOT_A_DOS_DISK: 225",
  38. "ERROR_NO_DISK: 226"
  39. };
  40.  
  41. /*---------------------------------------------------------------------*/
  42. /*                   AmigaDOS Error-Text outpur                        */
  43. /*                                                                     */
  44. /*                                                                     */
  45. /*---------------------------------------------------------------------*/
  46. LONG
  47. get_error()
  48. {
  49. LONG error;
  50.  
  51.    error = IoErr();
  52.  
  53.    if( error < 120 ){
  54.       switch( error ){
  55.       case 000:
  56.          printf( "All OK!\n" );
  57.          break;
  58.       case 103:
  59.          printf( "ERROR_NO_FREE_STORE: 103\n" );
  60.          break;
  61.       case 105:
  62.          printf( "ERROR_TASK_TABLE_FULL: 105\n" );
  63.          break;
  64.       case 120:
  65.          printf( "ERROR_LINE_TOO_LONG: 120\n" );
  66.          break;
  67.       case 121:
  68.          printf( "ERROR_FILE_NOT_OBJECT: 121\n" );
  69.          break;
  70.       case 122:
  71.          printf( "ERROR_INVALID_RESIDENT_LIBRARY: 122\n" );
  72.          break;
  73.       case 232:
  74.          printf( "ERROR_NO_MORE_ENTRIES: 232\n" );
  75.          break;
  76.       }
  77.    }
  78.    else{
  79.       printf( "%s\n", error_strs[error-201] );
  80.    }
  81.    return( error );
  82. }
  83.  
  84. /*---------------------------------------------------------------------*/
  85. /*                               Type                                  */
  86. /*                                                                     */
  87. /*                                                                     */
  88. /*---------------------------------------------------------------------*/
  89. type( filename )
  90. UBYTE *filename;
  91. {
  92. struct FileHandle *handle;
  93. struct FileHandle *Open();
  94. UBYTE buf;
  95. LONG read_length;
  96.  
  97.    handle = Open( filename, MODE_OLDFILE );
  98.  
  99.    if( handle ){
  100.       do{
  101.          read_length = Read( handle, &buf, 1L );
  102.          printf( "%c", buf );
  103.       }
  104.       while( read_length );
  105.       Close( handle );
  106.    }
  107.    else{
  108.       get_error();
  109.    }
  110. }
  111.  
  112. /*---------------------------------------------------------------------*/
  113. /*                           Main program                              */
  114. /*                                                                     */
  115. /*                                                                     */
  116. /*---------------------------------------------------------------------*/
  117. main( arg_num, args )
  118. int arg_num;
  119. char *args[];
  120. {
  121.    if( arg_num > 1 )
  122.       type( args[1] );
  123.    else
  124.       printf( "A file name is required!\n" );
  125. }
  126.  
  127.